<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<html:html locale="true">
<head>
	<title>File Upload2</title>
	<html:base />
</head>
<% 	String cpath = request.getContextPath(); %>
<script language=javascript>
			function toPreview(type,id){
				var value="Type="+type+"&amp;ObjectID="+id;
				if(navigator.appName=="Microsoft Internet Explorer"){
					top.B.location.href="<%=cpath%>/frame.do?Frame=12&Id=16&"+value;
				}else{
					value = value.replace(/&amp\;/g,"&");
					top.B.location.href="<%=cpath%>/frame.do?Frame=12&Id=16&"+value;
				}
			}  
 </script>
<body >

	<form action="materialFile.do" method="post" enctype="multipart/form-data">
		<logic:notEmpty name="materialId" >
			<input type="hidden" name="materialId" value='<bean:write name="materialId"/>'>
		</logic:notEmpty>
		<logic:notEmpty name="shotId" >
		<input type="hidden" name="shotId" value='<bean:write name="shotId"/>'>
		</logic:notEmpty>
		<logic:notEmpty name="elementId" >
		<input type="hidden" name="elementId" value='<bean:write name="elementId"/>'>
		</logic:notEmpty>
		<table>
		
			<tr>
				<td align="right">
					File Name
				</td>
				<td align="left">
					<input type="file" name="theFile" />
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<input type="submit" value="Upload File">
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<logic:notEmpty name="materialId" >
						<script language=javascript>
							toPreview("Material",<bean:write name="materialId"/>);
						</script>						
						</logic:notEmpty>
						<logic:notEmpty name="elementId" >
						<script language=javascript>
							toPreview("PreElement",<bean:write name="elementId"/>);
						</script>						
					</logic:notEmpty>
					
					<logic:notEmpty name="result">
						<font color="red">
							<logic:equal name="result" value="true">
								upload success		
							</logic:equal>
							<logic:equal name="result" value="false">
								upload error
							</logic:equal>
					   </font>
					</logic:notEmpty>
				</td>
			</tr>
		</table>
	</form>
</body>
</html:html>
